/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ImportFormDialogPane.java
 *
 * Created on 02-mar-2010, 17:06:10
 */

package geobloc.desktop.dialogs;

import java.util.Vector;
import javax.swing.AbstractListModel;

/**
 *
 * @author Usuario
 */
public class ImportFormDialogPane extends javax.swing.JPanel {

    /** Creates new form ImportFormDialogPane */
    public ImportFormDialogPane(final Vector<String> names) {
        initComponents();

        // Create the list and select the first element
        final Vector<String> strings = names;
        namesList.setModel(new AbstractListModel() {
            public int getSize() { return strings.size(); }
            public Object getElementAt(int i) { return strings.get(i); }
        });
        namesList.setSelectedIndex(0);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        titleLabel = new javax.swing.JLabel();
        listScrollPane = new javax.swing.JScrollPane();
        namesList = new javax.swing.JList();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(geobloc.desktop.FormDesignerApp.class).getContext().getResourceMap(ImportFormDialogPane.class);
        titleLabel.setText(resourceMap.getString("titleLabel.text")); // NOI18N
        titleLabel.setName("titleLabel"); // NOI18N

        listScrollPane.setName("listScrollPane"); // NOI18N

        namesList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        namesList.setName("namesList"); // NOI18N
        listScrollPane.setViewportView(namesList);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(listScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane listScrollPane;
    private javax.swing.JList namesList;
    private javax.swing.JLabel titleLabel;
    // End of variables declaration//GEN-END:variables

    public String getResults() {
        return (String)namesList.getSelectedValue();
    }

}
